package com.arcblock.demo.present

import com.arcblock.demo.inter.IGetDataInterface
import com.arcblock.demo.entity.Frontmatter

class MainPresenter(val main: IGetDataInterface) : GetDataPresenter() {
    /**
     * 使用异步获取数据
     */
    fun getMainInfo() {
        //异步访问
        val homeCall = service.getData()
        homeCall.enqueue(callback)
    }

    override fun transmitDatas(dataEntity: List<Frontmatter>) {

        //有数据，成功页面,刷新UI
        if (dataEntity!=null) {
            if(main!=null) {
                main.onMainSuccess(dataEntity)
            }
        } else {
            if(main!=null) {
                //无数据，可弹吐司
                main.onMainFailed()
            }
        }
    }
}
